package generic;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

class Book {
    private String name;

    public Book(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Book{" +
                "name='" + name + '\'' +
                '}';
    }
}

class Food {

}

public class GenericDemo {
    public static void main(String[] args) {

        List<Book> list = new ArrayList<Book>();
        list.add(new Book("三国演义"));
        list.add(new Book("红楼梦"));

        Iterator<Book> it = list.iterator();
        while (it.hasNext()) {
            Book b = it.next();
            System.out.println(b);
        }
    }

}
